#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

class A
{
	int i;
	A(int ii=0):i(ii)
	{
	   cout<<"ctor"<<endl;
	}
public:
       static A& instance()
       {
	       static A s(9);
	       return s;
       }
       
       int geti()
       {
	       return i;
       }

       void seti(int j)
       {
	      i = j;
       }
};

int  f(int i)
{
	static int o(8);
	if(i>o) o=i;
	return o;
}

int main(int argc, char **argv)
{
	A&  a=A::instance();
	A&  b=A::instance();
	a.seti(321);
	b.seti(123);

	cout<<a.geti()<<" "<<b.geti()<<endl; 
	A::instance();
	cout<<a.geti()<<" "<<b.geti()<<endl; 

	cout<<f(0)<<" "<<f(9)<<" "<<f(7)<<endl;
	return 0;
}
